#include <bits/stdc++.h>
using namespace std;
int con[100][101];

int main() {
	int term = 0;
	int ans[100] = {0};
	for (int i = 0; i < 100; ++i) {
		ans[i] = 0;
	}
	cin >> term;
	for (int i = 0; i < term; ++i) {
		int temp;
		cin >> temp;
		con[i][100] = temp;
		for (int j = 0; j < temp; ++j) {
			cin >> con[i][j];
		}
	}
	for (int i = 0; i < term; ++i) {
		sort(con[i], con[i] + con[i][100]);
	}

	for (int i = 0; i < term; ++i) {
		for (int j = 0; j < con[i][100] - 1; ++j) {
			for (int k = j; k < con[i][100] - 1; ++k) {
				for (int z = k + 1; z < con[i][100]; ++z) {
					if (con[i][j] + con[i][k] == con[i][z]) {
						ans[i]++;
					}
				}
			}
		}
	}
	for (int i = 0; i < term; ++i) {
		cout << ans[i] << endl;
	}

	return 0;
}